﻿@model LoginViewModel
@{
    ViewData["Title"] = "系统登录";
    Layout = null;
}

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>@ViewData["Title"]</title>
    <style>
        /* 精确匹配图片的样式（横向加宽版） */
        body {
            font-family: 'Microsoft YaHei', sans-serif;
            background: #f0f2f5;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            margin: 0;
        }

        .login-box {
            width: 600px; 
            background: white;
            box-shadow: 0 2px 10px rgba(0,0,0,0.1);
            border-radius: 8px;
            overflow: hidden;
        }

        /* 标题栏 */
        .login-header {
            background: linear-gradient(90deg, #3498db, #2ecc71);
            color: white;
            padding: 18px;
            text-align: center;
            font-size: 20px; 
            font-weight: bold;
            height: 56px; 
        }

        .login-body {
            padding: 28px; 
        }

        /* 选项卡*/
        .role-tabs {
            display: flex;
            margin-bottom: 28px;
            height: 50px;
            border-radius: 4px;
            overflow: hidden;
            border: 1px solid #e0e0e0;
        }

        .role-tab {
            flex: 1;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 16px;
            cursor: pointer;
            background: #f8f9fa;
        }

            .role-tab.active {
                background: #3498db;
                color: white;
            }

        /* 表单行 */
        .form-row {
            display: flex;
            margin-bottom: 22px;
            align-items: center;
        }

        .form-label {
            width: 80px;
            font-size: 15px;
            color: #333;
        }

        .form-input {
            flex: 1;
            padding: 9px 13px;
            border: 1px solid #ddd;
            border-radius: 4px;
            font-size: 15px;
            height: 45px; 
            box-sizing: border-box;
        }

        /* 登录按钮 */
        .login-btn {
            width: 100%;
            padding: 11px;
            background: linear-gradient(90deg, #3498db, #2ecc71);
            border: none;
            color: white;
            border-radius: 4px;
            font-size: 17px;
            cursor: pointer;
            margin-top: 11px;
            height: 50px;
        }

        
        .register-link {
            text-align: center;
            margin-top: 17px;
            font-size: 14px;
            color: #666;
        }

            .register-link a {
                color: #3498db;
                text-decoration: none;
                margin-left: 5px;
            }

        
        .text-danger {
            margin-left: 80px;
            font-size: 13px;
            color: #e74c3c;
            display: block;
            margin-top: 5px;
        }
    </style>
</head>
<body>
    <!-- 结构保持不变，仅尺寸放大 -->
    <div class="login-box">
        <div class="login-header">系统登录</div>
        <div class="login-body">
            <div class="role-tabs">
                <div class="role-tab active" data-role="admin">管理员</div>
                <div class="role-tab" data-role="customer">顾客</div>
            </div>
            <!-- 错误汇总 -->
            <div asp-validation-summary="All" class="text-danger"></div>
            <form asp-action="Login" method="post">
                <input type="hidden" name="UserType" id="selectedRole" value="Admin" />

                <div class="form-row">
                    <label class="form-label">登录名</label>
                    <input asp-for="LoginName" class="form-input" placeholder="请输入用户名">
                </div>
                <span asp-validation-for="LoginName" class="text-danger"></span>

                <div class="form-row">
                    <label class="form-label">密码</label>
                    <input asp-for="Password" type="password" class="form-input" placeholder="请输入密码">
                </div>
                <span asp-validation-for="Password" class="text-danger"></span>

                <button type="submit" class="login-btn">登录</button>
            </form>

            <div class="register-link">
                没有账号？<a href="@Url.Action("Register")">立即注册</a>
            </div>
        </div>
    </div>

    <script src="~/lib/jquery/dist/jquery.min.js"></script>
    <script>
                $(function() {
            // 初始化时根据 Model.UserType 设置 active 状态
            var userType = '@Model?.UserType';
            if (userType === 'Customer') {
                $('.role-tab[data-role="customer"]').addClass('active');
                $('.role-tab[data-role="admin"]').removeClass('active');
                $('#selectedRole').val('Customer');
            } else {
                $('.role-tab[data-role="admin"]').addClass('active');
                $('.role-tab[data-role="customer"]').removeClass('active');
                $('#selectedRole').val('Admin');
            }

            // 点击切换逻辑
            $('.role-tab').click(function() {
                $('.role-tab').removeClass('active');
                $(this).addClass('active');
                $('#selectedRole').val($(this).data('role') === 'admin' ? 'Admin' : 'Customer');
            });
        });
    </script>
</body>
</html>